<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        数量:
        <input type="text" id="num" value="1" oninput="abb()">
        单价:
        <input type="text" id="price"   value="1" oninput="baa()">
        总价
        <span id="pop"></span>
    </div>
    <script>
        var num = document.getElementById("num")
        var price = document.getElementById("price")
        var pop = document.getElementById("pop")
        pop.innerText = Number(num.value) * Number(price.value)
        function abb(){
            var abc = Number(num.value)
            pop.innerText = abc * Number(price.value)
        }
        function baa(){
            var cba = Number(price.value)
            pop.innerText = cba * Number(num.value)
        }
        
    </script>
</body>
</html>